<?php
// user group module access & modify
$access_module_checked = array();
$modify_module_checked = array();

foreach ($module_access->result() as $row_acc) {
	$access_id = $row_acc -> use_module_id;
	array_push($access_module_checked, $access_id);
}
foreach ($module_modify->result() as $row_mod) {
	$modify_module_id = $row_mod -> use_module_id;
	array_push($modify_module_checked, $modify_module_id);
}

// user module access & modify
$access_user_module_checked = array();
$modify_user_module_checked = array();

if($user_module_access->num_rows>0){
	foreach ($user_module_access->result() as $row_acc) {
		$access_id = $row_acc -> use_module_id;
		array_push($access_user_module_checked, $access_id);
	}	
}

if($user_module_modify->num_rows>0){
	foreach ($user_module_modify->result() as $row_mod) {
		$modify_module_id = $row_mod -> use_module_id;
		array_push($modify_user_module_checked, $modify_module_id);
	}	
}

?>
<br />
<form name=myform action="<?php echo base_url(); ?>user-permissions/user-modules/<?php echo $this->uri->segment(3);?>" method=post>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-info">
			<div class="panel-heading">
				<i class="fa fa-group fa-fw"></i> User  modules setting

				<div class="pull-right " style="margin-top: -7px;">
					
					<input type="submit" value="<?php echo $this -> lang -> line('button_update'); ?>" class="btn btn-primary"/>
					<input type="button" value="<?php echo $this -> lang -> line('button_cancel'); ?>" class="btn btn-primary" onclick="goBack()"/>
					
				</div>
			</div>
			<div class="panel-body">
				<div class="form-group form-inline col-lg-8">
				    <label for="user_group_name_disabled"><?php echo $this->lang->line('form_label_user_group_name');?> <span class="star_require">*</span></label>
				    <input type="text" class="form-control " name="user_group_name_disabled" id="user_group_name_disabled"  value="<?php echo $group_name;?>" disabled>
				    <input type="hidden" class="form-control " name="user_group_name" id="user_group_name"  value="<?php echo $group_name;?>">
				  </div>

				<div class="col-lg-6">
					<div class="panel panel-danger">
						<div class="panel-heading">
							<?php echo $this -> lang -> line('title_access_permissions'); ?>
						</div>
						<div class="panel-body">
							
								<table>
									<tr>
										<td><strong>Make a selection</strong>
										<br>
										<?php
											foreach($modules->result() as $row_access){
												$module_id=$row_access->module_id;
												$module_name=$row_access->name_lang_key;
												
												if(in_array($module_id,$access_module_checked)){
											      	$checked="checked";
											    }else{
											      	$checked="";
											     }
										?>
												<input type="checkbox" name="module_access_disabled[]" disabled="disabled" value="<?php echo $module_id; ?>" <?php echo $checked;?>>
												<?php echo $module_name; ?><br>
										<?php
										}
										?>
										</td>
									</tr>
								</table>

						</div>
						<div class="panel-footer">
							
						</div>
					</div>
				</div>
				<!-- /.col-lg-4 -->
				<div class="col-lg-6">
					<div class="panel panel-warning">
						<div class="panel-heading">
							<?php echo $this -> lang -> line('title_modify_permissions'); ?>
						</div>
						<div class="panel-body">
							
								<table>
									<tr>
										<td><strong>Make a selection</strong>
										<br>
										<?php
											foreach($modules->result() as $row_modify){
												$module_id=$row_modify->module_id;
												$module_name=$row_modify->name_lang_key;
												
												if(in_array($module_id,$modify_module_checked)){
											      	$checked="checked";
											    }else{
											      	$checked="";
											     }
										?>
												<input type="checkbox" name="module_modify_disabled[]" disabled="disabled" value="<?php echo $module_id; ?>" <?php echo $checked;?>>
												<?php echo $module_name; ?><br>
										<?php
										}
										?>
										</td>
									</tr>
								</table>

						</div>
						<div class="panel-footer">
							
						</div>
					</div>
				</div>
				<!-- /.col-lg-4 -->
				
				
				
				
				<div class="form-group form-inline col-lg-8">
				    <label for="user_group_name">Add / Update  modules to user beside module in user groups </label>
				   
				  </div>

				<div class="col-lg-6">
					<div class="panel panel-danger">
						<div class="panel-heading">
							<?php echo $this -> lang -> line('title_access_permissions'); ?>
						</div>
						<div class="panel-body">
							
								<table>
									<tr>
										<td><strong>Make a selection</strong>
										<br>
										<?php
											foreach($modules->result() as $row_access){
												$module_id=$row_access->module_id;
												$module_name=$row_access->name_lang_key;
												
												if(in_array($module_id,$access_user_module_checked)){
											      	$checked="checked";
											    }else{
											      	$checked="";
											     }
										?>
												<input type="checkbox" name="module_access[]" value="<?php echo $module_id; ?>" <?php echo $checked;?>>
												<?php echo $module_name; ?><br>
										<?php
										}
										?>
										</td>
									</tr>
								</table>

						</div>
						<div class="panel-footer">
							<!--<a href="">Select All</a> | <a href="">Unselect All</a>-->
							<!--<input type=button value="Check All" onClick="this.value=check(this.form.module_access)" class="btn btn-default">-->
								<input type="button" class="btn btn-default" onClick="checkAllAccess(true);" value="<?php echo $this -> lang -> line('button_check_all'); ?>"/>
<input type="button" class="btn btn-default" onClick="checkAllAccess(false);" value="<?php echo $this -> lang -> line('button_clear_all'); ?>"/>
						</div>
					</div>
				</div>
				<!-- /.col-lg-4 -->
				<div class="col-lg-6">
					<div class="panel panel-warning">
						<div class="panel-heading">
							<?php echo $this -> lang -> line('title_modify_permissions'); ?>
						</div>
						<div class="panel-body">
							
								<table>
									<tr>
										<td><strong>Make a selection</strong>
										<br>
										<?php
											foreach($modules->result() as $row_modify){
												$module_id=$row_modify->module_id;
												$module_name=$row_modify->name_lang_key;
												
												if(in_array($module_id,$modify_user_module_checked)){
											      	$checked="checked";
											    }else{
											      	$checked="";
											     }
										?>
												<input type="checkbox" name="module_modify[]" value="<?php echo $module_id; ?>" <?php echo $checked;?>>
												<?php echo $module_name; ?><br>
										<?php
										}
										?>
										</td>
									</tr>
								</table>

						</div>
						<div class="panel-footer">
							<!--<a href="">Select All</a> | <a href="">Unselect All</a>-->
							<!--<input type=button value="Check All" onClick="this.value=check(this.form.module_modify)" class="btn btn-default">-->
															<input type="button" class="btn btn-default" onClick="checkAll(true);" value="<?php echo $this -> lang -> line('button_check_all'); ?>"/>
<input type="button" class="btn btn-default" onClick="checkAll(false);" value="<?php echo $this -> lang -> line('button_clear_all'); ?>"/>
						</div>
					</div>
				</div>
				
			</div>
			<div class="panel-footer">
				&nbsp;
			</div>
		</div>
	</div>
	</form>
	<!-- /.col-lg-4 -->

</div>
<!-- /.row -->